//Nicccce
import React, {Component} from 'react';
import WeUI from 'react-weui';
import 'whatwg-fetch';
const {Dialog} = WeUI;

export default class ZoneListItem extends Component {
    constructor(props) {
        super(props);
        this.DetailClick = this.DetailClick.bind(this);
        this.CheckClick = this.CheckClick.bind(this);
    }

    componentWillMount() {

    }

    CheckClick() {
        let incubatorId=this.props.incubatorId;
        this.props.callbackParent(incubatorId);
    }

    DetailClick() {
        location.hash = "/ZoneDetail?incubatorId="+this.props.incubatorId;
    }


    render() {
        let btn_text = "";
        if (this.props.online) {
            btn_text = "去预定";
        } else {
            btn_text = "暂未开放";
        }
        let str = "";
        if (!this.props.path) {
            str = "url('/iot-meeting/assets/images/confirm/zone_default.png')";
        } else {
            str = "url('" + this.props.path + "')";
        }
        return (
            <div className="zone_itemStyle">
                <div className="zone_imgStyle" style={{
                    background: str, backgroundRepeat: "no-repeat",
                    backgroundSize: "cover"
                }}>
                    <div className="zone_textStyle">{this.props.name}</div>
                </div>
                <div className="zone_itemBottom">
                    <div className="zone_halfLayout"><span onClick={this.DetailClick}>查看园区介绍</span></div>
                    <div className="zone_halfLayout">
                        <div className="zone_checkBtn" onClick={this.CheckClick}>{btn_text}</div>
                    </div>
                </div>
            </div>
        )
    }


}

//属性默认值
ZoneListItem.defaultProps = {
    online: false,
};

//属性
ZoneListItem.propTypes = {
    provinceId: React.PropTypes.number,
    incubatorId: React.PropTypes.number,
    name: React.PropTypes.string,
    path: React.PropTypes.string,
    online: React.PropTypes.bool,
};